package com.kingyea.mobilepolice.organizationcopy.controller;

import com.kingyea.mobilepolice.organizationcopy.bean.OrganizationCopy;
import com.kingyea.mobilepolice.organizationcopy.service.OrganizationCopyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description OrganizationCopy 控制层
 * @date Created in 2018-03-30 15:30:32
 */
@RequestMapping(value = "/organizationCopy")
@RestController
public class OrganizationCopyController {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrganizationCopyController.class);

    @Autowired
    private OrganizationCopyService organizationCopyService;

    /**
     * 查询全部
     *
     * @param
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public List<OrganizationCopy> list() throws Exception {
        return organizationCopyService.search(null);
    }

    /**
     * 通过ID查找对象
     *
     * @param orgId
     * @return
     */
    @RequestMapping(value = "/{orgId}", method = RequestMethod.GET)
    public OrganizationCopy detail(@PathVariable Integer orgId) throws Exception {
        return organizationCopyService.getById(orgId);
    }

    /**
     * 创建
     *
     * @param organizationCopy
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public OrganizationCopy create(@RequestBody OrganizationCopy organizationCopy) throws Exception {
        return organizationCopyService.save(organizationCopy);
    }

    /**
     * 更新
     *
     * @param organizationCopy
     * @return
     */
    @RequestMapping(method = RequestMethod.PUT)
    public OrganizationCopy update(@RequestBody OrganizationCopy organizationCopy) throws Exception {
        return organizationCopyService.update(organizationCopy);
    }

    /**
     * 删除
     *
     * @param orgId
     * @return
     */
    @RequestMapping(value = "/{orgId}", method = RequestMethod.DELETE)
    public int delete(@PathVariable Integer orgId) throws Exception {
        return organizationCopyService.deleteById(orgId);
    }

}
